package com.kitty.game.equip.service;

import com.kitty.common.utils.SpringUtils;
import com.kitty.game.equip.message.RespNotifyMiscEx;
import com.kitty.game.equip.model.RoleEquip;
import com.kitty.game.gm.handler100.NCChongzhi;
import com.kitty.game.gm.handler100.NCGmFather;
import com.kitty.game.role.model.Role;
import com.kitty.mina.cache.DataCache;
import com.kitty.mina.message.MessagePusher;
import org.springframework.stereotype.Service;

@Service
public class ChongZhiKaService {
    /**
     * 1元·充值卡
     * 5元·充值卡
     * 10元·充值卡
     * 20元·充值卡
     * 30元·充值卡
     * 128元·充值卡
     * 328元·充值卡
     * 648元·充值卡
     * 1998元·充值卡
     * @param role
     * @param itemName
     * @param roleEquip
     */
    public void addRoleRechargeCard(Role role, String itemName, RoleEquip roleEquip){
        int money = 0;
        switch (itemName){
            case "1元·充值卡":
                money = 1;
                break;
            case "5元·充值卡":
                money = 5;
                break;
            case "10元·充值卡":
                money = 10;
                break;
            case "20元·充值卡":
                money = 20;
                break;
            case "30元·充值卡":
                money = 30;
                break;
            case "128元·充值卡":
                money = 128;
                break;
            case "328元·充值卡":
                money = 328;
                break;
            case "648元·充值卡":
                money = 648;
                break;
            case "1998元·充值卡":
                money = 1998;
                break;
        }
        if (SpringUtils.getEquipService().delEquipNum(role, roleEquip, 1) <= 0) {
            return;
        }


        if(money>0){
            role.getExtendBox().setTotalChargeCard(role.getExtendBox().getTotalChargeCard() + money);
            SpringUtils.getBean(HDDSService.class).linquChongzhiKa(role);
        }

        int bili  = Integer.parseInt(DataCache.REDIS_DATA.get("chongzhikabili"));
        money = money * bili;
        if(money > 0) {
            SpringUtils.getRoleService().addRechargeScore(role, money);
            MessagePusher.pushMessage(role, new RespNotifyMiscEx("使用充值卡额外积分已发放！"));

        }
    }
}
